


<!DOCTYPE html>
<html id="htmlId">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
  <title>Coverage Report > GoodsServiceImpl</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/idea.min.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.min.js"></script>
  <script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">com.ie.service.admin</a>
</div>

<h1>Coverage Summary for Class: GoodsServiceImpl (com.ie.service.admin)</h1>

<table class="coverageStats">

<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Branch, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">GoodsServiceImpl</td>
<td class="coverageStat">
  <span class="percent">
    11.1%
  </span>
  <span class="absValue">
    (1/9)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/40)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    1.4%
  </span>
  <span class="absValue">
    (1/73)
  </span>
</td>
</tr>
  <tr>
    <td class="name">GoodsServiceImpl$$SpringCGLIB$$0</td>
  </tr>
<tr>
  <td class="name"><strong>Total</strong></td>
<td class="coverageStat">
  <span class="percent">
    11.1%
  </span>
  <span class="absValue">
    (1/9)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/40)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    1.4%
  </span>
  <span class="absValue">
    (1/73)
  </span>
</td>
</tr>
</table>

<br/>
<br/>


<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package com.ie.service.admin;
&nbsp;
&nbsp;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
&nbsp;import com.baomidou.mybatisplus.core.metadata.IPage;
&nbsp;import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
&nbsp;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
&nbsp;import com.ie.common.http.ResponseResult;
&nbsp;import com.ie.common.security.utils.MyUtil;
&nbsp;import com.ie.entity.admin.CartEntity;
&nbsp;import com.ie.entity.admin.GoodsEntity;
&nbsp;import com.ie.entity.before.FocusEntity;
&nbsp;import com.ie.mapper.admin.GoodsMapper;
&nbsp;import com.ie.service.before.FocusService;
&nbsp;import org.springframework.beans.factory.annotation.Autowired;
&nbsp;import org.springframework.stereotype.Service;
&nbsp;
&nbsp;import java.io.File;
&nbsp;import java.io.FileNotFoundException;
&nbsp;import java.io.FileOutputStream;
&nbsp;import java.io.IOException;
&nbsp;import java.util.HashMap;
&nbsp;import java.util.List;
&nbsp;import java.util.Map;
&nbsp;
&nbsp;@Service
<b class="fc">&nbsp;public class GoodsServiceImpl extends ServiceImpl&lt;GoodsMapper, GoodsEntity&gt; implements GoodsService {</b>
&nbsp;
&nbsp;    @Autowired
&nbsp;    private GoodsMapper goodsMapper;
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;Map&lt;String, Object&gt;&gt; getGoods(GoodsEntity goodsEntity) {
<b class="nc">&nbsp;        Integer currentPage = goodsEntity.getCurrentPage();</b>
<b class="nc">&nbsp;        if (currentPage == null || currentPage &lt; 1) {</b>
<b class="nc">&nbsp;            goodsEntity.setCurrentPage(1);</b>
&nbsp;        }
<b class="nc">&nbsp;        IPage&lt;GoodsEntity&gt; iPage = new Page&lt;&gt;(goodsEntity.getCurrentPage(), 5);</b>
<b class="nc">&nbsp;        LambdaQueryWrapper&lt;GoodsEntity&gt; lambdaQueryWrapper = new LambdaQueryWrapper&lt;&gt;();</b>
<b class="nc">&nbsp;        Integer goodstypeId = goodsEntity.getGoodstypeId();</b>
<b class="nc">&nbsp;        String gname = goodsEntity.getGname();</b>
<b class="nc">&nbsp;        if (goodstypeId != null &amp;&amp; goodstypeId != 0) {</b>
<b class="nc">&nbsp;            lambdaQueryWrapper.eq(GoodsEntity::getGoodstypeId, goodstypeId);</b>
&nbsp;        }
<b class="nc">&nbsp;        if (gname != null &amp;&amp; !gname.isEmpty()) {</b>
<b class="nc">&nbsp;            lambdaQueryWrapper.like(GoodsEntity::getGname, gname);</b>
&nbsp;        }
<b class="nc">&nbsp;        IPage&lt;GoodsEntity&gt; page = goodsMapper.iPageGoods(iPage, lambdaQueryWrapper);</b>
&nbsp;
<b class="nc">&nbsp;        HashMap&lt;String, Object&gt; myres = new HashMap&lt;&gt;();</b>
<b class="nc">&nbsp;        myres.put(&quot;allGoods&quot;, page.getRecords());</b>
<b class="nc">&nbsp;        myres.put(&quot;totalPage&quot;, page.getPages());</b>
&nbsp;
<b class="nc">&nbsp;        return ResponseResult.getSuccessResult(myres);</b>
&nbsp;    }
&nbsp;
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;List&lt;GoodsEntity&gt;&gt; getAdvGoods() {
<b class="nc">&nbsp;        List&lt;GoodsEntity&gt; listAdv = lambdaQuery().eq(GoodsEntity::getIsAdvertisement, 1)</b>
<b class="nc">&nbsp;                .orderByDesc(GoodsEntity::getId).last(&quot;limit 5&quot;).list();</b>
<b class="nc">&nbsp;        return ResponseResult.getSuccessResult(listAdv);</b>
&nbsp;    }
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;GoodsEntity&gt; getGoodsById(GoodsEntity goodsEntity) {
<b class="nc">&nbsp;        return ResponseResult.getSuccessResult(getById(goodsEntity.getId()));</b>
&nbsp;    }
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;List&lt;GoodsEntity&gt;&gt; getGoodsIndex(GoodsEntity goodsEntity) {
<b class="nc">&nbsp;        LambdaQueryWrapper&lt;GoodsEntity&gt; lambdaQueryWrapper = new LambdaQueryWrapper&lt;&gt;();</b>
<b class="nc">&nbsp;        Integer goodstypeId = goodsEntity.getGoodstypeId();</b>
<b class="nc">&nbsp;        String gname = goodsEntity.getGname();</b>
&nbsp;
<b class="nc">&nbsp;        if (goodsEntity.getGoodstypeId() != null &amp;&amp; goodsEntity.getGoodstypeId() != 0) {</b>
<b class="nc">&nbsp;            lambdaQueryWrapper.eq(GoodsEntity::getGoodstypeId, goodstypeId);</b>
&nbsp;        }
&nbsp;
<b class="nc">&nbsp;        if (gname != null) {</b>
<b class="nc">&nbsp;            String trimmedGname = gname.trim();</b>
<b class="nc">&nbsp;            if (!trimmedGname.isEmpty()) {</b>
<b class="nc">&nbsp;                lambdaQueryWrapper.like(GoodsEntity::getGname, trimmedGname);</b>
&nbsp;            }
&nbsp;        }
<b class="nc">&nbsp;        lambdaQueryWrapper.orderByDesc(GoodsEntity::getId).last(&quot;limit 15&quot;);</b>
&nbsp;
<b class="nc">&nbsp;        List&lt;GoodsEntity&gt; listIndex = list(lambdaQueryWrapper);</b>
<b class="nc">&nbsp;        return ResponseResult.getSuccessResult(listIndex);</b>
&nbsp;    }
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;Map&lt;String, String&gt;&gt; addGoods(GoodsEntity goodsEntity) {
<b class="nc">&nbsp;        byte[] logoFile = goodsEntity.getLogoFile();</b>
<b class="nc">&nbsp;        if (logoFile != null &amp;&amp; logoFile.length &gt; 0) {</b>
<b class="nc">&nbsp;            String path = &quot;F:\\ebusiness-vue\\src\\assets&quot;;</b>
<b class="nc">&nbsp;            String fileName = MyUtil.getNewFileName(goodsEntity.getFileName());</b>
<b class="nc">&nbsp;            File filePath = new File(path + File.separator + fileName);</b>
<b class="nc">&nbsp;            if (!filePath.getParentFile().exists()) {</b>
<b class="nc">&nbsp;                filePath.getParentFile().mkdirs();</b>
&nbsp;            }
&nbsp;            try {
<b class="nc">&nbsp;                FileOutputStream fileOutputStream = new FileOutputStream(filePath);</b>
<b class="nc">&nbsp;                fileOutputStream.write(logoFile);</b>
&nbsp;            } catch (IOException e) {
<b class="nc">&nbsp;                throw new RuntimeException(e);</b>
&nbsp;            }
<b class="nc">&nbsp;            goodsEntity.setGpicture(fileName);</b>
&nbsp;        }
<b class="nc">&nbsp;        if (&quot;add&quot;.equals(goodsEntity.getAct())) {</b>
<b class="nc">&nbsp;            boolean success = save(goodsEntity);</b>
<b class="nc">&nbsp;            if (success) {</b>
<b class="nc">&nbsp;                return ResponseResult.getMessageResult(null, &quot;A001&quot;);</b>
&nbsp;            } else {
<b class="nc">&nbsp;                return ResponseResult.getMessageResult(null, &quot;A002&quot;);</b>
&nbsp;            }
&nbsp;        } else {
<b class="nc">&nbsp;            boolean success = updateById(goodsEntity);</b>
<b class="nc">&nbsp;            if (success) {</b>
<b class="nc">&nbsp;                return ResponseResult.getMessageResult(null, &quot;A001&quot;);</b>
&nbsp;            } else {
<b class="nc">&nbsp;                return ResponseResult.getMessageResult(null, &quot;A002&quot;);</b>
&nbsp;            }
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;Map&lt;String, String&gt;&gt; deleteGoods(GoodsEntity goodsEntity) {
<b class="nc">&nbsp;        Integer goodsId = goodsEntity.getId();</b>
<b class="nc">&nbsp;        long res1 = 0;</b>
<b class="nc">&nbsp;        long res2 = 0;</b>
<b class="nc">&nbsp;        long res3 = 0;</b>
&nbsp;
<b class="nc">&nbsp;        if (res1 &gt; 0 || res2 &gt; 0 || res3 &gt; 0) {</b>
<b class="nc">&nbsp;            return ResponseResult.getMessageResult(null, &quot;A001&quot;);</b>
&nbsp;        }
<b class="nc">&nbsp;        boolean result = removeById(goodsId);</b>
<b class="nc">&nbsp;        if (result) {</b>
<b class="nc">&nbsp;            return ResponseResult.getMessageResult(null, &quot;A002&quot;);</b>
&nbsp;        } else {
<b class="nc">&nbsp;            return ResponseResult.getMessageResult(null, &quot;A003&quot;);</b>
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;List&lt;Map&lt;String, Object&gt;&gt;&gt; myCartGoods(CartEntity cartEntity) {
<b class="nc">&nbsp;        List&lt;Map&lt;String, Object&gt;&gt; list = goodsMapper.myCartGoods(cartEntity.getBusertableId());</b>
<b class="nc">&nbsp;        return ResponseResult.getSuccessResult(list);</b>
&nbsp;    }
&nbsp;
&nbsp;    @Override
&nbsp;    public ResponseResult&lt;Map&lt;String, Object&gt;&gt; iPageMyFocusGoods(GoodsEntity goodsEntity) {
<b class="nc">&nbsp;        IPage&lt;GoodsEntity&gt; iPage = new Page&lt;&gt;(goodsEntity.getCurrentPage(), 5);</b>
<b class="nc">&nbsp;        LambdaQueryWrapper&lt;FocusEntity&gt; queryWrapper = new LambdaQueryWrapper&lt;&gt;();</b>
<b class="nc">&nbsp;        queryWrapper.eq(FocusEntity::getBusertableId, goodsEntity.getBusertableId());</b>
<b class="nc">&nbsp;        IPage&lt;GoodsEntity&gt; page = goodsMapper.iPageMyFocusGoods(iPage, queryWrapper);</b>
<b class="nc">&nbsp;        HashMap&lt;String, Object&gt; myres = new HashMap&lt;&gt;();</b>
<b class="nc">&nbsp;        myres.put(&quot;allGoods&quot;, page.getRecords());</b>
<b class="nc">&nbsp;        myres.put(&quot;totalPage&quot;, page.getPages());</b>
&nbsp;
<b class="nc">&nbsp;        return ResponseResult.getSuccessResult(myres);</b>
&nbsp;    }
&nbsp;}
</code>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
      hljs.highlightAll()
      hljs.initLineNumbersOnLoad();
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2025-06-15 18:23</div>
</div>
</body>
</html>
